home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’92 / DylanTalk / DylanTalk Source / DylanTalk.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-14  |  4.7 KB  |  137 lines  |  [TEXT/MPS ]

  1. #ifndef __DYLANTALK__
  2. #define __DYLANTALK__
  3.  
  4. #ifndef __WINDOWS__
  5. #include <Windows.h>
  6. #endif
  7.  
  8. #ifndef __DIALOGS__
  9. #include <Dialogs.h>
  10. #endif
  11.  
  12. #ifndef __MENUS__
  13. #include <Menus.h>
  14. #endif
  15.  
  16. #ifndef __SOUND__
  17. #include <Sound.h>
  18. #endif
  19.  
  20. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  21. // types
  22.  
  23. //    I have declared a few TYPEs below to help examine 'snd ' resources.
  24. //    I have to break them up into individual pieces because they are
  25. //    variable sized records. 
  26.  
  27. typedef struct {
  28.     short format;
  29.     short numSynths;
  30. } Snd1Header, *Snd1HdrPtr, **Snd1HdrHndl;
  31.  
  32. typedef struct {
  33.     short synthID;
  34.     long  initOption;
  35. } SynthInfo, *SynthInfoPtr;
  36.  
  37. typedef struct {
  38.     short format;
  39.     short refCount;
  40. } Snd2Header, *Snd2HdrPtr, **Snd2HdrHndl;
  41.  
  42. typedef SndCommand *SndCmdPtr;    // Ptr to a sound command, for type coersion 
  43.  
  44. typedef struct _res_map res_map;
  45. typedef struct _res_map *res_map_ptr;
  46. typedef struct _res_map **res_map_handle;
  47.  
  48. struct _res_map {
  49. long            void1;        /* Reserved */
  50. long            void2;        /* Reserved */
  51. long            void3;        /* Reserved */
  52. long            void4;        /* Reserved */
  53. res_map_handle    next_map;    /* Handle of next resource map */
  54. short            refNum;        /* fRefNum for this file */
  55. short            fileAttrs;    /* Resource file attributes for this file */
  56. short            tlOffset;    /* Type List Offset from beginning of map */
  57. short            nlOffset;    /* Name List Offset from beginning of map */
  58. };
  59.  
  60. #define kNumCachedDialogs 5
  61.  
  62. struct WordQueue {
  63.         Handle            aWord[0];
  64. };
  65. typedef struct WordQueue WordQueue, *WordQueuePtr;
  66.  
  67. struct DylanTalkGlobals {
  68.         DialogPtr        openDialogs[kNumCachedDialogs];                // Dialogs we’ve already talked about
  69.         PicHandle        aboutPicture;                                // Handle to DylanTalk about box
  70.         StringPtr        firstDialogString;                            // String we’re going to say
  71.         WordQueuePtr    wordQueue;                                    // Queue of said words
  72.         SndChannelPtr    dylanSndChannel;                            // Sound channel
  73.         Handle            dylanTalkIcons;                                // Handle to DylanTalk menu icons
  74.         StringHandle    preferencesFileName;                        // Name of preferences file
  75.         long            preferencesDirID;                            // Directory ID if DylanTalk Preferences folder
  76.         short            preferencesVRefNum;                            // VRefNum of DylanTalk Preferences
  77.         short            personalityFile;                            // File reference number of current personality file
  78.         short            personalityItem;                            // Item number in menu of current personality;
  79.         Boolean            playingControlSound;                        // True if we’re speaking a button title
  80. };
  81. typedef struct DylanTalkGlobals DylanTalkGlobals, *DylanTalkGlobalPtr, **DylanTalkGlobalHandle;
  82.         
  83. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  84. // constants 
  85.  
  86. #define kNoComp            'NONE'
  87. #define k3to1Comp        'MAC3'
  88. #define k6to1Comp        'MAC6'
  89. #define kNumChannels    1                        // one channel in the sound header
  90. #define kContinousOn    1
  91. #define kContinousOff    0
  92.  
  93. #define    kDylanTalkPersonalityFileType    'Prsn'
  94. #define    kDylanTalkCreator                'DTlk'
  95. #define gestaltDylanTalk                kDylanTalkCreator
  96.  
  97. #define    rDylanTalkPreferencesFile        128        // 'STR ' resource containing name of preferences folder and file
  98. #define    rDefaultPersonality                129        // 'STR ' resource containing name of default personality
  99. #define    rPreferredPersonality            130        // 'STR ' resource containing name of preferred personality
  100.  
  101. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  102. // macros 
  103.  
  104. // Define HiWrd and LoWrd macros for efficiency. 
  105. #define HiWrd(aLong)    (((aLong) >> 16) & 0xFFFF)
  106. #define LoWrd(aLong)    ((aLong) & 0xFFFF)
  107.  
  108. #define WindowList (*(WindowPeek*)0x9D6)
  109.  
  110. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  111. // Routine prototypes 
  112.  
  113. #pragma parameter __D0 StringToNumber(__A0)
  114. pascal long StringToNumber(ConstStr255Param theString)
  115.  = {0x3F3C,0x0001,0xA9EE};
  116.  
  117. Handle PlayWord(SndChannelPtr channel,  StringPtr word, short refNum);
  118. Boolean CheckForNumber(ConstStr255Param word);
  119. OSErr PlaySound(Handle theSound,SndChannelPtr channel );
  120. Handle GetSoundResourceForWord(ConstStr255Param word);
  121. void AddSound(Handle sndHandle,SndChannelPtr channel);
  122. long GetBufferOffset(Handle sndHandle);
  123. void QuietChannel(SndChannelPtr channel);
  124. void KillChannel( SndChannelPtr channel, Boolean waitForSoundToFinish );
  125. void FreeQueue(DylanTalkGlobalPtr globals);
  126. pascal void SpeakStringSounds(DylanTalkGlobalPtr globals);
  127. pascal void KillStringSounds(DylanTalkGlobalPtr globals);
  128. pascal void ConvertStringToUpperCase(StringPtr text);
  129. pascal Boolean FindCharacterRun(StringPtr text, short offset, StringPtr stringToSpeak, short *runStartOffset);
  130.  
  131. pascal void OpenPersonalityFile(void);
  132. pascal void ChooseNewPersonality(short itemNumber, MenuHandle personalityMenu);
  133. pascal short SwitchPersonalityFile(Str255 personalityFile);
  134. pascal void FillPersonalityMenu(MenuHandle personalityMenu);
  135.  
  136. pascal void DylanTalkAbout(void);
  137. #endif